<template>
<div class="home-box" style="margin-left:20px;">
    <el-form :inline="true" :model="searchForm">
      <el-form-item label="员工姓名">
        <el-input
          v-model="searchForm.empName"
          placeholder="员工姓名"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="岗位名称">
        <el-input
          v-model="searchForm.position"
          placeholder="岗位名称"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="部门名称">
        <el-input
          v-model="searchForm.dept"
          placeholder="岗位名称"
          clearable
        ></el-input>
      </el-form-item>
	  <el-form-item label="当前状态">
	    <el-input
	      v-model="searchForm.auditStatus"
	      placeholder="当前状态"
	      clearable
	    ></el-input>
	  </el-form-item>
      <el-form-item>
        <el-button @click="searchEvent" type="primary">查询 </el-button>
      </el-form-item>
	  
	  
      <el-form-item>
        <el-button @click="update" type="primary">重置 </el-button>
      </el-form-item>
	  
	  <el-form-item>
		  是否查看所有：
		<el-switch
		    v-model="searchForm.flag"
		    active-value="false"
		    inactive-value="true"
			@change="update">
		  </el-switch>
	  </el-form-item>
	  
	  <el-form-item v-auth="'进度条导出'">
	      <el-button color="#ff983f" :dark="isDark" plain icon="Download" @click="handleOut"
	  >导出</el-button>
	    </el-form-item>
		
		<el-form-item v-auth="'导出超时人员导出'">
		    <el-button color="#ff983f" :dark="isDark" plain icon="Download" @click="handleOut1"
		>导出超时人员名单</el-button>
		  </el-form-item>
		
		
      <el-form-item >
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button circle icon="Refresh" @click="update" />
        </el-tooltip>
      </el-form-item>
    </el-form>
  </div>
  <el-table
    :data="PositionList"
    style="width: 100%; margin: 5px; border-radius: 5px;box-shadow: 5px 5px 10px rgba(51, 126, 204, 0.5)"
    size="large"
    :header-cell-style="{
      background: '#626aef !important',
      color: '#ffffff',
      border: 'none !important',
    }"
  >
    <el-table-column
      prop="empName"
      label="员工姓名"
      width="75"
    >
    </el-table-column>
    <el-table-column prop="position" label="岗位" width="85" />
    <el-table-column prop="deptName" label="所属部门" width="85" />
	<el-table-column prop="auditStatus" label="当前状态" width="85">
		<template #default="scope" style="white-space: pre-line;">
			{{scope.row.auditStatus == 0? "未考核":
				scope.row.auditStatus == 1?"考核中":
				scope.row.auditStatus == 2?"暂停":"考核完成"}}
		</template>
	</el-table-column>
    <el-table-column prop="items" label="进度" direction="vertical" style="white-space: pre-line;">
        <template #default="scope" style="white-space: pre-line;">
			<el-steps :active="scope.row.orderStatus" finish-status="success" class="step" space="350px" style="white-space: pre-line;" >
					<el-step :title="item.title" :description="item.description" v-for="(item,index) in scope.row.items" :key="index" style="white-space: pre-line;">{{item.description}}</el-step>
				
			</el-steps>
			
        </template>
    </el-table-column>
  </el-table>
</template>


<script setup>
import { ref, onMounted, onBeforeMount, reactive, watch } from "vue";
import { Timer } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import { getProgress,searchProgress} from "@/api/progress";
import { ElMessage } from "element-plus";
import {downLoadProgress,downPerson} from "@/api/downExcel"

const searchForm = ref({
  position: "",
  empName:"",
  dept:"",
  flag:true,
  auditStatus:"",
  empId:JSON.parse(localStorage.getItem("userInfo")).id,
});

const empId = JSON.parse(localStorage.getItem("userInfo")).id;

const PositionList = ref([]);
onBeforeMount(() => {
	var flag = searchForm.value.flag
	
  getProgress({empId,flag}).then((data) => {
    PositionList.value = data.data;
    
  });
});
watch(
  PositionList,
  (newVal) => {
    
  },
  { deep: true }
);

const searchEvent = () => {
  searchProgress(searchForm.value).then((data) => {
    PositionList.value = data.data;
  });
};

const update = () => {
  searchForm.value.position = "";
  searchForm.value.dept = "";
  searchForm.value.empName = "";
  // searchForm.value.auditStatus = "";
  var flag = searchForm.value.flag
  
  getProgress({empId,flag}).then((data) => {
    PositionList.value = data.data;
  });
};

const handleOut=()=>{
  downLoadProgress()
}


const handleOut1=()=>{
  downPerson()
}


</script>

<style lang="scss" scoped>
:deep(.my-content) {
  background: rgba(98, 106, 239,0.2)!important;
  font-size: 15px;
  white-space: pre-line;
}
.pagination {
  margin: 20px 50px;
  display: flex;
  justify-content: end;
  white-space: pre-line;
}
::v-deep .el-step__head.is-process {
  color: rgb(52, 158, 250);
  border-color: rgb(52, 158, 250);
  white-space: pre-line;
}
::v-deep .el-step__title.is-process {
    font-weight: bold;
    color: rgb(52, 158, 250);
	white-space: pre-line;
}
::v-deep .el-step__description.is-process {
    color: rgb(52, 158, 250);
	white-space: pre-line;
}
.multiline-description .el-step__description {
  white-space: pre-line; /* 或者使用 normal; */
}
</style>
